home *** CD-ROM | disk | FTP | other *** search
- ;void write_right_b(strg,col,row,color);
- ; unsigned char *strg,col,row,color;
-
- EXTRN _memory_model:byte
- EXTRN _video_page:byte
-
- _TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TEXT
- PUBLIC _write_right_b
- _write_right_b proc near
- push bp ;
- mov bp,sp ;set stack frame
- push di ;
- push si ;
- cmp _memory_model,0 ;near or far?
- jle begin ;jump if near
- inc bp ;else add 2 to BP
- inc bp ;
- begin: push ds ;save DS
- mov bh,_video_page ;set the video page
- cmp _memory_model,2 ;data near or far?
- jb L0 ;jump if near
- lds si,dword ptr[bp+4] ;DS:SI pts to Strg
- inc bp ;add 2 to BP since dword ptr
- inc bp ;
- jmp short L00 ;
- L0: mov si,[bp+4] ;near case
- L00: mov bl,[bp+10] ;attribute in BL
- mov dh,[bp+8] ;Row
- dec dh ;count from zero
- mov dl,[bp+6] ;Col
- dec dl ;count from zero
- sub cx,cx ;clear CX
- cmp byte ptr[si],0 ;test for null string
- je L2 ;
- L000: inc si ;move SI to end of string
- inc cx ;inc string length counter
- cmp byte ptr[si],0 ;test for end of string
- jne L000 ;loop
- dec si ;pull back pointer
- mov di,cx ;keep Strg ctr in DI
- mov cx,1 ;write 1 char each time
- L1: mov ah,2 ;function to set cursor
- int 10h ;set the cursor
- mov ah,9 ;function to write char
- mov al,[si] ;get a character
- int 10h ;write it
- dec si ;forward Strg ptr
- dec dl ;dec column position
- cmp dl,-1 ;test for left margin
- je L2 ;quit if margin
- dec di ;dec Strg length counter
- jnz L1 ;loop till finished
- L2: pop ds ;
- pop si ;
- pop di ;
- pop bp ;
- cmp _memory_model,0 ;quit
- jle quit ;
- db 0CBh ;RET far
- quit: ret ;RET near
- _write_right_b endp
- _TEXT ENDS
- END